import yang.java8.util.Util;

/**
 * 尾递归效率高， java无此功能
 * @author xinxin
 *
 */
public class WeiDiGui {

	public static void main(String[] args) {
		int index = 10;
		long now = Util.showTime(System.currentTimeMillis());
		System.out.println(commonFi(index));
		now = Util.showTime(now);
		System.out.println(WeiFi(index, 1));
		now = Util.showTime(now);
	}
	
	public static int commonFi(int n) {
		if (n == 1) {
			return 1;
		}
		return n * commonFi(n - 1);
	}
	
	public static int WeiFi(int n,int value) {
		if (n == 1) {
			return value;
		}
		
		return WeiFi(n - 1, value * n);
	}

}
